#chmod 755 pour le repertoire
IMPUTEDIR=/commun/data/pubdb/mathgen.stats.ox.ac.uk/impute/_ignore.backup/ALL_1000G_phase1integrated_v3_impute
DBHOME=/commun/data/pubdb/mathgen.stats.ox.ac.uk/impute/_ignore.backup/impute.berkeleydb
LIB=/usr/local/package/je-4.0.103/lib/je-4.0.103.jar
#INSTALLDIR=/commun/data/pubdb/mathgen.stats.ox.ac.uk/impute/_ignore.backup/bin
INSTALLDIR=/commun/data/users/simonet/fsimonet/BIMREADER/bin/
all:
	echo "specify target"

${INSTALLDIR}/je.jar : ${LIB}
	cp $< $@

bimreader: ${INSTALLDIR}/je.jar
	mkdir -p dist
	mkdir -p tmp/META-INF
	javac -cp ${LIB}:. -d tmp/ fr/inserm/um915/jimpute/model/BimReader.java
	echo -e "Manifest-Version: 1.0\nClass-Path: ${INSTALLDIR}/je.jar\nMain-Class: fr.inserm.um915.jimpute.model.BimReader"> tmp/jeter.manifest
	jar cvfm dist/bimreader.jar tmp/jeter.manifest -C tmp .
	rm -rf tmp

guessbuild: ${INSTALLDIR}/je.jar
	mkdir -p dist
	mkdir -p tmp/META-INF
	javac -cp ${LIB}:. -d tmp/ fr/inserm/um915/jimpute/model/GuessBuild.java
	echo -e "Manifest-Version: 1.0\nClass-Path: ${INSTALLDIR}/je.jar\nMain-Class: fr.inserm.um915.jimpute.model.GuessBuild"> tmp/jeter.manifest
	jar cvfm dist/guessbuild.jar tmp/jeter.manifest -C tmp .
	rm -rf tmp


build: ${INSTALLDIR}/je.jar
	mkdir -p dist
	mkdir -p tmp/META-INF
	javac -cp ${LIB}:. -d tmp/ fr/inserm/um915/jimpute/model/ModelBuilder.java
	echo -e "Manifest-Version: 1.0\nClass-Path: ${INSTALLDIR}/je.jar\nMain-Class: fr.inserm.um915.jimpute.model.ModelBuilder"> tmp/jeter.manifest
	jar cvfm dist/impute-builder.jar tmp/jeter.manifest -C tmp .
	rm -rf tmp
	java -jar dist/impute-builder.jar -d ${DBHOME} -i ${IMPUTEDIR} \
		--proxy proxy-upgrade.univ-nantes.prive:3128 \
		-s hg18 http://hgdownload.cse.ucsc.edu/goldenPath/hg18/database/snp130.txt.gz \
		-s hg19 http://hgdownload.cse.ucsc.edu/goldenPath/hg19/database/snp135.txt.gz \
		-m /commun/data/pubdb/ncbi/_ignore.backup/snp/RsMergeArch.bcp.gz

test1: guessbuild
	curl -s "http://hgdownload.cse.ucsc.edu/goldenPath/hg18/database/snp130.txt.gz" | gunzip -c |\
	cut -d '	' -f 2,3,5 |\
	head -n 1000 |\
		java -jar dist/guessbuild.jar -d ${DBHOME}
		
test2: bimreader
		java -Xmx3G -jar dist/bimreader.jar -d ${DBHOME} -L ALL -m jeter.err.gz \
			/commun/data/users/simonet/server3/dina_tmp/GWAS_PVM_XJ/GWAS_marqueurs_rares/suvipvmXJ23.bim  > jeter.bom
install: guessbuild bimreader
	cp  dist/bimreader.jar dist/guessbuild.jar ${INSTALLDIR}
